var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (i, e) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, i) {
              t.__proto__ = i;
            }) ||
          function (t, i) {
            for (var e in i)
              Object.prototype.hasOwnProperty.call(i, e) && (t[e] = i[e]);
          })(i, e);
      };
      return function (i, e) {
        function n() {
          this.constructor = i;
        }
        if ("function" != typeof e && null !== e)
          throw new TypeError(
            "Class extends value " + String(e) + " is not a constructor or null"
          );
        t(i, e),
          (i.prototype =
            null === e
              ? Object.create(e)
              : ((n.prototype = e.prototype), new n()));
      };
    })(),
  AXGiveGiftView = (function (t) {
    function i() {
      var i = t.call(this) || this;
      return (
        (i.max = 99),
        (i.min = 1),
        (i.step = 1),
        (i.num = 1),
        (i.onLoadShopListData = {
          caller: i,
          code: 1269,
          method: function (t) {
            0 == t.code
              ? (ToastView.toastView("购买成功"),
                WebSocketService.send({ c: 1266, d: { pageNum: 0 } }),
                WebSocketService.send({ c: 1451, d: { pageNum: 0 } }))
              : ToastView.toastView(t.msg),
              i.close();
          },
        }),
        (i.onLoadBackShopItemData = {
          caller: i,
          code: 1271,
          method: function (t) {
            0 == t.code
              ? (ToastView.toastView("回购成功"),
                WebSocketService.send({ c: 1266, d: { pageNum: 0 } }))
              : ToastView.toastView(t.msg),
              i.close();
          },
        }),
        i.btn_gift_plus.on(Laya.Event.CLICK, i, i.onAddPlusGiftItemFn),
        i.btn_gift_delete.on(Laya.Event.CLICK, i, i.onDeleteGiftItemFn),
        i.gift_slider.on(Laya.Event.CHANGE, i, i.sliderPitchChangeFn),
        i.btn_gift_buy.on(Laya.Event.CLICK, i, i.onGiveGiftDidClickFn),
        i.btn_gift_cancle.on(Laya.Event.CLICK, i, i.close),
        WebSocketService.addListener(i.onLoadShopListData),
        WebSocketService.addListener(i.onLoadBackShopItemData),
        WebSocketService.addListener(i.onLoadShopListData),
        WebSocketService.addListener({
          caller: i,
          code: 1296,
          method: i.onLoadBackShoppingActionFn,
        }),
        i
      );
    }
    return (
      __extends(i, t),
      (i.show = function (t) {
        null == this.give_gift && (this.give_gift = new i()),
          this.give_gift.popup(!0),
          (this.give_gift.giftArr = t),
          (this.give_gift.gift_type = ""),
          (this.give_gift.gift_price = t.price),
          this.give_gift.setupGiveGiftBaseView(),
          (this.give_gift.gift_slider.max = this.give_gift.max),
          (this.give_gift.gift_slider.min = this.give_gift.min),
          (this.give_gift.step = 1),
          (this.give_gift.min = 1),
          (this.give_gift.gift_count = 1),
          (this.give_gift.lbl_gift_num.text = "1"),
          (this.give_gift.lbl_gift_sum.text = t.price),
          (this.give_gift.btn_gift_buy.label = "购买"),
          this.give_gift.updateMedicalData();
      }),
      (i.showBackShop = function (t, e) {
        null == this.give_gift && (this.give_gift = new i()),
          this.give_gift.popup(!0),
          (this.give_gift.giftArr = t),
          (this.give_gift.gift_type = e),
          (this.give_gift.gift_price = t.price),
          this.give_gift.setupGiveGiftBaseView(),
          (this.give_gift.gift_count = 1),
          (this.give_gift.gift_slider.max = this.give_gift.giftArr.num),
          (this.give_gift.gift_slider.min = this.give_gift.min),
          (this.give_gift.step = 1),
          (this.give_gift.max = this.give_gift.giftArr.num),
          (this.give_gift.lbl_gift_num.text = "1"),
          (this.give_gift.lbl_gift_sum.text = t.price),
          (this.give_gift.gift_slider.value = this.give_gift.min),
          (this.give_gift.btn_gift_buy.label = "回收"),
          this.give_gift.updateMedicalData();
      }),
      (i.prototype.updateMedicalData = function () {
        this.gift_slider.value = this.gift_count;
      }),
      (i.prototype.sliderPitchChangeFn = function () {
        (this.gift_count = this.gift_slider.value),
          (this.lbl_gift_num.text = this.gift_slider.value + ""),
          (this.lbl_gift_sum.text =
            this.gift_slider.value * this.gift_price + "");
      }),
      (i.prototype.onAddPlusGiftItemFn = function () {
        (this.gift_count = this.gift_count + this.step),
          this.gift_count > this.max && (this.gift_count = this.max),
          (this.gift_slider.value = this.gift_count);
      }),
      (i.prototype.onDeleteGiftItemFn = function () {
        (this.gift_count = this.gift_count - this.step),
          this.gift_count < this.min && (this.gift_count = this.min),
          (this.gift_slider.value = this.gift_count);
      }),
      (i.close = function () {
        this.give_gift && this.give_gift.close();
      }),
      (i.prototype.onGiveGiftDidClickFn = function () {
        var t = this.giftArr.id;
        "backbuy_zahuo" == this.gift_type
          ? WebSocketService.send({
              c: 1271,
              d: { id: t, count: this.gift_count },
            })
          : "backbuy_kuangshi" == this.gift_type
          ? WebSocketService.send({
              c: 1296,
              d: { id: t, count: this.gift_count },
            })
          : WebSocketService.send({
              c: 1269,
              d: { id: t, count: this.gift_count, type: 0 },
            });
      }),
      (i.prototype.setupGiveGiftBaseView = function () {
        (this.lbl_gift_title.text = this.giftArr.name),
          (this.lbl_gift_content.text = this.dealMsgFn(this.giftArr.name));
      }),
      (i.prototype.onLoadBackShoppingActionFn = function (t) {
        0 == t.code
          ? (ToastView.toastView("回收成功 " + t.msg),
            WebSocketService.send({ c: 1277, d: { pageNum: 0 } }),
            WebSocketService.send({ c: 1451, d: { pageNum: 0 } }))
          : ToastView.toastView(t.msg),
          this.close();
      }),
      (i.prototype.dealMsgFn = function (t) {
        return "鲜花" == t
          ? "送给女性，友好度+10"
          : "酒菜" == t
          ? "送给男性，友好度+10"
          : "路书" == t
          ? "可瞬间回到居住地"
          : "香案" == t
          ? "结义、创建教派所用道具"
          : "大包裹" == t
          ? "有效期10天，增加100负重上限"
          : "小包裹" == t
          ? "有效期10天，增加50负重上限"
          : "";
      }),
      i
    );
  })(ui.MarketController.AXGiveGiftsViewUI);
